<script setup lang="ts">
import { ref, onMounted, inject } from 'vue';
import Login from './Login.vue';
import { useUserStore } from '../stores/user';
const userSotre = useUserStore()
const isLogin = ref(false)
import { setWinSizeKey, setSearchTagKey } from '../model/type'
const handleWinSize = inject(setWinSizeKey)
const setTag = inject(setSearchTagKey)
onMounted(() => {
    setTag!('我的账户')
    handleWinSize!()
})
const login = () => {
    showLogin.value = true

}
const logout = () => {
    userSotre.logout()

}
const showLogin = ref(false)
onMounted(() => {
    // const userinfo = userSotre.getUserInfo()
    // if (userinfo.userId != '') {
    //     isLogin.value=true

    // }
})

</script>
<template >
    <n-space vertical align="center" data-tauri-drag-region>
        <n-avatar round :size="48" src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg" />
        <n-button type="primary" v-if="isLogin" size="medium" @click="logout"></n-button>
        <n-button type="primary" v-if="!isLogin" size="medium" @click="login">登录Mlink</n-button>
        <n-modal v-model:show="showLogin">
            <Login></Login>
        </n-modal>
    </n-space>
</template>
<style scoped></style>